package org.tech4j.springboot.starter.edi.common;

import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.tech4j.edi.base.config.RetryPoolConfig;
import org.tech4j.edi.base.threadpool.RetryThreadPoolFactory;

/**
 * @program: tech4j
 * @description:
 * @author: YuKai Fan
 * @create: 2025/3/10 11:32
 **/
@Configuration
public class RetryPoolConfiguration {

    @Bean
    @ConfigurationProperties(prefix = "tech4j.edi.retry.pool")
    public RetryPoolConfig retryPoolConfig() {
        return new RetryPoolConfig();
    }

    @Bean
    public ApplicationRunner applicationRunner(RetryPoolConfig retryPoolConfig) {
        return args -> RetryThreadPoolFactory.createRetryThreadPool(retryPoolConfig);
    }
}
